<template>
  <el-dialog
    :visible="dialogVisible"
    append-to-body
    width="20rem"
    title="新增"
    @close="$emit('close')"
  >
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
    >
      <el-form-item
        label="表名"
        prop="tableName"
      >
        <el-input
          v-model="form.tableName"
          placeholder="模糊匹配，例如：tmp\_%"
          clearable
        />
      </el-form-item>
    </el-form>
    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        @click="$emit('close')"
      >取 消</el-button>
      <el-button
        type="primary"
        @click="addUatBlackList"
      >确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import uatSyncApi from '@/api/dashboard/uatSync'
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      form: {
        tableName: ''
      },
      rules: {
        tableName: [
          { required: true, message: '请输入表名', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    addUatBlackList() {
      this.$refs.form.validate(valid => {
        if (valid) {
          const data = {
            tblName: this.form.tableName
          }
          uatSyncApi.addUatBlackList(data).then(res => {
            this.$message({
              message: '添加成功',
              type: 'success'
            })
            this.$emit('close')
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
